<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>localStorage 对象</title>
</head>
<body>

<div id="result"></div>

<script>
  if (typeof(Storage) !== "undefined") {
    localStorage.setItem("lastname","Gates");
    document.getElementById("result").innerHTML = localStorage.getItem("lastname");
  } else {
    document.getElementById("result").innerHTML = "抱歉！您的浏览器不支持 Web Storage ...";
  }
</script>

</body>
</html>